<?php

class PLFTemplate{
	
	private $_vars;
	
	public $tplfile;
	
	public function __construct($tplfile = null){
		$this->tplfile=$tplfile;
	}
	
	public function set($name,$value){
		$this->_vars[$name] = $value;
	}
	
	public static function widget($widget_name,$tmpl){
		return new PLFTemplate(PLF::$widget_path . $widget_name . "/" . $tmpl . ".tpl.php");
	}
	
	public function fetch(){
   		 ob_start();                    // Start output buffering
  	     @extract($this->_vars);
   		 include($this->tplfile);                // Include the file
   		 $contents = ob_get_contents(); // Get the contents of the buffer
   		 ob_end_clean(); 
   		 return $contents;
	}
	
	public function show(){
		echo $this->fetch();
	}
}

?>